package common.components
{
	import flash.events.MouseEvent;      
    import mx.containers.Box;      
    import mx.containers.DividedBox;      
    import mx.controls.Image;      
  

	public class DividerBox extends Box
	{      
        [Embed(source='/assets/images/expand_left.gif')]      
        public static const DividerIcon_left:Class;        
              
        [Embed(source='/assets/images/expand_right.gif')]      
        public static const DividerIcon_right:Class;    
        
		private var image:Image = new Image();      
        private var bOpened:Boolean = true;      
        private var dividbox:DividedBox = null;      
              
        public function DividerBox()      
         {      
            super();      
            this.width = 16;      
            this.height = 16;      
            this.clipContent   = true;      
            image.width = 16;      
            image.height = 16;                
            this.addChild( image );      
     
            //我这个是在一个HdividedBox中，其默认对dividerbox进行了旋转，所以需要旋转回来。      
            image.rotation = 90;      
                  
            this.addEventListener(MouseEvent.CLICK,onMouseClick);      
         }      
              
         override protected function createChildren():void{      
            super.createChildren();      
             dividbox = this.parent.parent.parent as DividedBox;      
             image.source = DividerIcon_left;      
         }      
              
        public function onMouseClick(event:MouseEvent):void{      
            if(bOpened){      
                 image.source = DividerIcon_right;      
                 dividbox.getChildAt(0).width = 0;      
                 bOpened = false;      
             }else{      
                 bOpened = true;      
                 image.source = DividerIcon_left;      
                 dividbox.getChildAt(0).width = 180;      
             }      
         }      
              
     }      
}    